package com.terrynoya.fight.evaluation.token
{
	import com.terrynoya.fight.evaluation.Node;
	import com.terrynoya.fight.evaluation.ParseState;
	
	import org.as3commons.reflect.Method;
	import org.as3commons.reflect.Type;

	public class CustomFunctionData extends NodeData
	{
		private var _type:Type;
		
		private var _parse:Method;
		
		public function CustomFunctionData(text:String, functionName:String,type:Type)
		{
			super(text, functionName);
			this._type = type;
			this._parse = type.getMethod("parse");
		}
		
		public function get type():Type
		{
			return _type;
		}

		public function parse(parseState:ParseState):Node
		{
			return this._parse.invoke(this._type.clazz,[parseState]);	
		}
	}
}